<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <#include "/pubHeadStyle.html">
</head>
<body>
<form class="layui-form" style="padding:0 30px 0 0;height: 200px;" >
    <div class="layui-form-item">
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">设置分类:</label>
        <div class="layui-input-block categorySet">
            <select id="categorySelect" name="categorySelect" lay-filter="category"></select>
            <input type="hidden" name="selectedIds" value="${selectedIds!''}" class="layui-input">
        </div>
    </div>
</form>
<script>
    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','form', 'layedit', 'laydate', 'jquery', 'table', 'commons'], function () {
        var form = layui.form
            , layer = layui.layer;
        var table = layui.table;
        var setter = layui.setter;
        var commons = layui.commons;
        var $ = layui.$;

        //重新渲染表单
        function renderForm(){
            layui.use('form', function(){
                var form = layui.form;//高版本建议把括号去掉，有的低版本，需要加()
                form.render();
            });
        }

        $.ajax({
            url: serverPath.systemPath + setter.sysLinkPath + "globalType/list",
            type: "POST",
            data:{catKey: "FLOW_TYPE", hasRoot: 0},
            dataType:"json",
            success: function (result) {
                var data = result.data;
                $.each(data, function (i, category) {
                    var optionStr = "<option value='" + category.typeId + "'>" + category.typeName + "</option>";
                    $("#categorySelect").append(optionStr);
                });
                renderForm();
            }
        });

        window.save =  function (callback) {
            $.ajax({
                url: serverPath.workflowPath + setter.workflowLinkPath + "actDefModel/categorySet" ,
                data:{
                    categorySelect:$("select[name=categorySelect]").val(),
                    selectedIds:$("input[name=selectedIds]").val()
                },
                type: 'post',
                dataType:'json',
                success: function (result) {
                    var index = parent.layer.getFrameIndex(window.name);
                    if (result.code === 0) {
                        parent.layer.alert(result.msg, function (index2) {
                            parent.layer.close(index2);
                            parent.layer.close(index);
                            if (callback){
                                callback();
                            }
                        });
                    } else {
                        parent.layer.alert(result.msg);
                    }
                }
            });
            return false;

        };

        $(".cancelForm").click(function () {
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        });
    })
</script>
<style>
    .categorySet .layui-anim-upbit{
        height: 136px;
    }
</style>
</body>
</html>